<?php //echo '<pre>';die(print_r($data));?>
<script>
    $(document).on('click', '.filter', function(){
        $('.filterBox').slideDown();
        $('.filter').hide();
        return false;
    });
    $(document).on('click', '.cancelFilter', function(){
        $('.filterBox').slideUp();
        $('.filter').show();
        return false;
    });
</script>
<div class="breadcrumbwidget">
	<ul class="skins">
        <li><a href="default" class="skin-color default"></a></li>
        <li><a href="orange" class="skin-color orange"></a></li>
        <li>&nbsp;</li>
        <li class="fixed"><a href="" class="skin-layout fixed"></a></li>
        <li class="wide"><a href="" class="skin-layout wide"></a></li>
    </ul><!--skins-->
	<ul class="breadcrumb">
        <li><a href="<?php echo $baseurl?>">Trang chủ</a> <span class="divider">/</span></li>
        <li class="active">Danh sách E-counpon</li>
    </ul>
</div><!--breadcrumbwidget-->
<div class="pagetitle">
	<h1>Danh sách E-counpon</h1> <span></span>
</div>
<div class="maincontent">
    <div class="contentinner">    
    
        <?php $attr = array('class' => 'stdform','id' => 'form-list'); echo form_open('', $attr);?>
        <div id="dyntable_length" class="dataTables_length  content-dashboard" style="position: relative;">
        <input type="hidden" name="check-delete" value="1" />
        
            <a href="<?php echo $baseurl.'manage/ecoupon/add-ecoupon'?>" class="btn"><i class="icon-plus"></i> Thêm mới</a>
            <!--<button class="btn" type="button" onclick="deleteall()"><i class="icon-remove"></i> Xóa đã chọn</button>-->
            
            <button class="btn filter" style="position: absolute; right: 10px; top: 10px;">Filter</button>
            <div class="clear"></div>
            <div class="filterBox" style="padding: 10px 0; display: none;">
                <div class="line clearfix">
                    <div class="col-3">
                        <label>Tìm theo từ khóa</label>
                        <input type="text" name="keyword" value="" placeholder="Nhập từ khóa"/>
                    </div>
                    <div class="col-3">
                        <label>Nhãn áp dụng</label>
                        <select name="label">
                        <option value="">Chọn nhãn</option>
                        <?php foreach($listLabel AS $key => $value):?>
                            <option value="<?php echo $value['id'];?>"><?php echo $value['name'];?></option>
                        <?php endforeach?>
                        </select>
                    </div>
                    <div class="col-3">
                        <label>Người tạo</label>
                        <select name="manager">
                        <option value="">Chọn tài khoản</option>
                        <?php foreach($listManager AS $key => $value):?>
                            <option value="<?php echo $value['id'];?>"><?php echo $value['username'];?></option>
                        <?php endforeach?>
                        </select>
                    </div>
                </div>
                <div>
                    <button type="submit" class="btn btn-success">Lọc</button>
                    <a class="btn btn-cancel cancelFilter">Hủy</a>
                </div>
        </div>
        </div>
    	<table class="table table-bordered">
            <colgroup>
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
            </colgroup>
            <thead>
                <tr>
                	<th class="centeralign" style="width: 5%;"><input type="checkbox" class="checkall" /></th>
                    <!-- <th style="width: 8%;">STT</th>
                    
					<th style="width: 80px">QrCode</th>
                    <th>Mã E-coupon</th> -->
                    <th>Tên E-coupon</th>
					<th style="width: 80px;">Hình ảnh</th>
					<th>Số lượng</th>
					<th>Đã nhận</th>
                    <th>Hạn sử dụng</th>
                    <th>Người tạo</th>
                    <th>Trạng thái</th>
                    <th class="centeralign" style="width: 10%">Tác vụ</th>
                </tr>
            </thead>
            <tbody>
            <?php $i=1; if(!in_array($data, array(null, '', '0'))):?>
            <?php foreach($data AS $el=>$le):?>
                <tr>
                	<td class="centeralign"><input name="checkboxs[]" id="<?php echo $le->id?>" type="checkbox" value="<?php echo $le->id?>" /></td>
                    
                    <td><?php echo $le->title?></td>
					 <td><img style="height: 75px;width: 75px;" src="<?php echo $imgbase.$le->img_thumbnail;?>" onError="this.src='<?php echo $baseurl."public/theme/manage/img/gray_jean.png";?>'"/></td> 
					<td><?php echo $le->amount?></td>
					<td><?php echo $le->amount_available;?></td>
                    <td><?php echo $fview->conVertTimeStamp($le->date_user, '/')?> 
					</td>
                    <td><?php echo $le->username?></td>
                    <td><?php echo $le->active == 1 && $le->date_user > time() ? '<small style="color: #46a73e;font-size: 12px">Hoạt động</small>' : '<small style="color: #FF0000;font-size: 12px">Hết hạn</small>'?>
					<?php if( $le->amount_available >= $le->amount ){ echo '<br><small style="color: #DF2929;font-size: 12px">Đã dùng hết</small>';} ?>
					</td>
                    <td class="centeralign">
                        <a href="<?php echo $baseurl.'manage/ecoupon/edit-ecoupon/'.$le->id?>" class=""><span class="icon-edit"></span></a>
                        <a href="<?php echo $baseurl.'manage/ecoupon/delete-ecoupon/'.$le->id?>" class="delete-a"><span class="icon-trash"></span></a>   
                    </td>
                </tr>
            <?php $i++; endforeach;?>
            <?php endif?>
            </tbody>
        </table>
        <div class="dataTables_info" id="dyntable_info">
            <div class="pagination">
                <?php echo $this->pagination->create_links();?> 
            </div>
        </div>
        </form>
    </div>
</div>
<style>
.table th, .table td {
vertical-align: middle !important;
}
</style>